$(function () {
    var firstMenu = "";
    var outpatientName = $('#outpatientName').val();
    var toUrl = Feng.ctxPath + "/index" ;
    $("#listOne").on('click', 'div', function () {
        var code = $(this).attr("id");
        $(this).addClass('actionClick').css("opacity", "1").siblings().removeClass('actionClick').css("opacity", "0.5");
        firstMenu = $(this).children('p').text();
        if (firstMenu === "市场" || firstMenu === "报表" || firstMenu === "基础" || firstMenu === "系统" || firstMenu === "审核" || firstMenu === "日志" || firstMenu === "病例评选") {
            $("#marketSearch").show().siblings().hide();
        } else if (firstMenu === "到店") {
            $("#foregroundSearch").show().siblings().hide();
        } else if (firstMenu === "结账") {
            $("#doctorTcSearchs").show().siblings().hide();
        } else if (firstMenu === "医生" || firstMenu === "质量检测") {
            $("#doctorSearch").show().siblings().hide();
        } else if (firstMenu === "TC") {
            $("#doctorTcSearch").show().siblings().hide();
        } else if (firstMenu === "客维") {
            $("#guestDimensionSearch").show().siblings().hide();
        }
        $.ajax({
            url: Feng.ctxPath + "/getChildrenValue",
            type: "post",
            data: {
                code: code
            },
            success: function (data) {
                var li = "";
                for (var i = 0; i < data.length; i++) {
                    li += '<li><a class="J_menuItem" href="' + Feng.ctxPath  + data[i].url + '" target="iframe0" name="tabMenuItem"><span>' + data[i].name + '</span></a></li>'
                }
                document.getElementById('side-menu').innerHTML = li;
                $("#side-menu > li").eq(0).click();
                toUrl = $("#side-menu > li:first-of-type").find('a:eq(0)').attr('href')
                document.getElementById("childrenIframe").src = toUrl;
            },
            error: function (data) {
                alert('没有权限，请联系系统管理员!');
                parent.layer.close(parent.layer.getFrameIndex(window.name));
            }
        });
    });
    $("#side-menu").on('click', 'li', function () {
        $(this).addClass('liClick').siblings().removeClass('liClick');
        var twoMenu = $(this).text();
        var menuShow = firstMenu + " > " + twoMenu;
        $("#currentSeat").html(menuShow);
        $("#page-middle input").val("");
        $("#pageStart").val("1")
    });
    $("#listOne > div").eq(0).click();
});